 
package at.ac.tuwien.ifs.calendit.dao;

import java.util.List;



/**
 * Generic Interface for all Data Access Objects Includes methods for adding,
 * editing, deleting, deleting all, searching and retrievint items.
 * 
 * @param <T>
 *            generic parameter <T> as placeholder for entities
 */

public interface IGenericDAO<T> {

	/**
	 * Inserts one object into the database. This method uses a transaction
	 * manager for performing two queries in one transaction:
	 * 
	 * @param object
	 *            - data of one object
	 * @return unique id generated by database assigned to the newly created
	 *         object
	 */
	public T add(T type);

	/**
	 * Edits one object into the database. This method uses a transaction
	 * manager for performing two queries in one transaction:
	 * 
	 * @param object
	 *            - data of one object
	 * @return Edited object or null on fail
	 */
	public T update(T typ);

	/**
	 * Deletes one object from the database.
	 * 
	 * @param object
	 *            IDs
	 * @return true or false
	 */
	public boolean delete(int typ_id);

	/**
	 * Deletes all objects from the database.
	 */
	public boolean deleteAll();

	/**
	 * Get an object by his ID
	 * 
	 * @param id
	 *            - ID of the object
	 * @return object - foundet object would be returned
	 */

	/**
	 * Get objects in choosed order
	 * 
	 * @param orderby
	 *            - name of the order
	 * @return objects ordered by parameter
	 */
	public List<T> getAll();

	public T getById(int id);

/*	*//**
	 * Get objects in choosed order and type
	 * 
	 * @param orderby
	 *            - name of the order
	 * @param type
	 *            - type of object who should be ordered
	 * @return objects ordered by parameter
	 *//*
	public List<T> getAll(String orderby, T type);*/
}
